//
//  IGUploadImageApi.m
//  jingdongfang
//
//  Created by BOE on 2017/9/20.
//  Copyright © 2017年 LJL. All rights reserved.
//

#import "IGUploadImageApi.h"
#import "AFNetworking.h"

@interface IGUploadImageApi()

@property (nonatomic, strong) UIImage *image;

@end

@implementation IGUploadImageApi

- (id)initWithImage:(UIImage *)image {
    self = [super init];
    if (self) {
        _image = image;
    }
    return self;
}

- (YTKRequestMethod)requestMethod {
    return YTKRequestMethodPOST;
}

- (NSString *)requestUrl {
    return @"member/uploadImage";
}

- (NSTimeInterval)requestTimeoutInterval {
    return 30;
}

- (AFConstructingBlock)constructingBodyBlock {
    __weak typeof(self) weakSelf = self;
    return ^(id<AFMultipartFormData> formData) {
        NSData *data = UIImageJPEGRepresentation(weakSelf.image, 0.1);
        NSString *name = @"jpg";
        NSString *formKey = @"pic";
        NSString *type = @"image/jpg";
        [formData appendPartWithFileData:data name:formKey fileName:name mimeType:type];
    };
}

@end
@implementation IGUploadImageModel

@end
@implementation IGUploadImageResp

@end
